package at.spengergasse.web.session;

import java.io.Serializable;

import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

@SuppressWarnings("serial")
public abstract class SessionData implements Serializable,
    HttpSessionBindingListener {
  protected final Log logger = LogFactory.getLog(getClass());

  public abstract String getSessionKey();

  public void valueBound(HttpSessionBindingEvent event) {
    if (logger.isDebugEnabled()) {
      logger.debug(new StringBuilder(event.getSession().getId()).append(
          " - bind attribute: ").append(event.getName()).append(" - ").append(
          event.getValue()).toString());
    }
  }

  public void valueUnbound(HttpSessionBindingEvent event) {
    if (logger.isDebugEnabled()) {
      logger.debug(new StringBuilder(event.getSession().getId()).append(
          " - unbind attribute: ").append(event.getName()).append(" - ").append(
          event.getValue()).toString());
    }
  }
}
